<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page import="java.util.*" %>
<%@ page import="org.news.entity.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>登录</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/login.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.3.1.js"></script>
<script type="text/javascript">
function sub() {
	//id是用户名
	var $uid=$("#uid").val();
	var $upwd=$("#upwd").val();
	var $vpwd=$("#vpwd").val();
	$.ajax({
			url:"/NewsManager_SSM/managerServlet/login",
			type:"post",
			data:"id="+$uid+"&upwd="+$upwd+"&vpwd="+$vpwd, 
			success:function(result,testStatus)
			{
				if(result == "1"){
					alert("登录成功");	
					//跳转
					location.href="/NewsManager_SSM";
				}else if(result=="2"){
					alert("验证码错误");
				}else{
					alert("账号或密码错误");
				}
			},
			error:function(xhr,errrorMessage,e){
				alert("系统异常！");
			}
		});
	}
function reloadCheckImg()
{
    $("#img").attr("src", "/NewsManager_SSM/view/other/validate.jsp?t="+(new Date().getTime()));  //<img src="...">
}
</script>
<%          
         manager mg=(manager) session.getAttribute("user");   
%>
</head>
<body>
<!-- 页面头部   -->
<header id="header_div">
  <div class="container">
	<div class="logo left">
		<img src="${pageContext.request.contextPath}/img/logo2.jpg" width="700" height="90">
	</div>
	<ul class="right">
		<li><a href="${pageContext.request.contextPath}/view/login/addMg.jsp">马上注册</a></li>
		<li><a href="${pageContext.request.contextPath}/index.jsp">返回主页</a></li>
	</ul>
  </div>
</header>
<!--表单部分-->
<div id="form_div">
  <form id="form">
	<br />
	<p align="center">用户登录</p>
	<p class="form_p">
		<strong style="font-size: 18px; color: white;">用户名：</strong>
		<input type="text" placeholder="请输入手机号码/用户名" name="uid" id="uid"\>
	</p>
	<p class="form_p">
		<strong style="font-size: 18px; color: white;">&nbsp;&nbsp;&nbsp;密码：</strong>
		<input type="password" placeholder="请输入密码" name="upwd" id="upwd" />
	</p>
	<p class="form_p">
		<strong style="font-size: 18px; color: white;">验证码：</strong>
		<input type="text" placeholder="请输入验证码" name="vpwd" id="vpwd" style="width: 100px;" />
	    <a href="javascript:reloadCheckImg();">  <img border=0 id="img" src="${pageContext.request.contextPath}/view/other/validate.jsp" >  </a>
	</p>

	<p style="position: absolute; right: 1%; color: #000000; top: 170px;">
		<a href="https://www.baidu.com" target="_blank">忘记密码？</a>
	</p>
  </form>
		<br />
		<!--提交按钮-->
		<div id="button_div">
			<button onclick="sub()">确认登录</button>
			<a href="/NewsManager_SSM/admin/login"><button style="margin-left: 30px;"> 管理员登录</button></a>
		</div>
	</div>

	<!--页脚部分-->

	<div id="footer">
		<div class="container">
			<p>
				<img src="img/i-f-logo.png"> <span>@2020 北京市xxxxxxx</span> <a
					href="#">版权说明</a> <a href="#">版权说明</a> <a href="#">版权说明</a> <a
					href="#">版权说明</a> <a href="#">版权说明</a>
			</p>
		</div>
	</div>
</body>
</html>